﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using MiniStock.BusinessLogic.EntityPersister;
using MiniStock.Infrastructure;
using Microsoft.Practices.Unity;


namespace MiniStockEventPersisterHost
{
    public partial class EventPersisterService : ServiceBase
    {
        private PersisterEventQueueWorker _queueWorker;

        public EventPersisterService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            using (new MiniStockContextScope())
            {
                _queueWorker = MiniStockContext.Current.RootContainer.Resolve<PersisterEventQueueWorker>();
                _queueWorker.Configure();
                _queueWorker.Start();
            }
        }

        protected override void OnStop()
        {
            _queueWorker.Stop();
        }
    }
}
